//
//  NSString+BZCodec.m
//  BZFoundation
//
//  Created by 郭艺伟 on 2017/10/1.
//  Copyright © 2017年 郭艺伟. All rights reserved.
//

#import "NSString+BZCodec.h"
#import <Availability.h>
#import "NSData+BZCodec.h"
@implementation NSString (BZCodec)
+ (NSString *)bz_stringWithBase64EncodedString:(NSString *)string {
    NSData *data = [NSData bz_dataWithBase64EncodedString:string];
    if (data) {
        return [[self alloc] initWithData:data encoding:NSUTF8StringEncoding];
    }
    return nil;
}

- (NSString *)bz_base64EncodedString {
    NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
    return [data bz_base64EncodedString];
}

- (NSString *)bz_base64EncodedStringWithWrapWidth:(NSUInteger)wrapWidth {
    NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
    return [data bz_base64EncodedStringWithWrapWidth:wrapWidth];
}

- (NSString *)bz_base64DecodedString {
    return [NSString bz_stringWithBase64EncodedString:self];
}

- (NSData *)bz_base64DecodedData {
    return [NSData bz_dataWithBase64EncodedString:self];
}


@end
